package com.kaifamiao.utils;

import com.alibaba.druid.pool.DruidDataSource;

import javax.sql.DataSource;

public class DataSourceUtils {

    private static DruidDataSource dataSource;

    public static void init(){
        dataSource = new DruidDataSource();
        dataSource.setDriverClassName( "com.mysql.cj.jdbc.Driver" );
        dataSource.setUrl( "jdbc:mysql://localhost:3306/kaifamiao?serverTimezone=Asia/Chongqing" );
        dataSource.setUsername( "kfm" );
        dataSource.setPassword( "kfm" );
    }

    public static DataSource getDataSource(){
        return dataSource;
    }

    public static void destory(){
        dataSource.close();
    }

}
